﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AcmeSportsStore
{
    public partial class PasswordView : Form
    {
        public PasswordView()
        {
            InitializeComponent();
        }

        public string LoginName
        {
            get
            {
                return tBoxName_PF.Text;
            }
        }

        private void btnOk_PF_Click(object sender, EventArgs e)
        {
            bool loginSucc = AccountsStore.TryLogin(
                tBoxName_PF.Text, tBoxPassword_PF.Text);
            if (loginSucc == true)
            {
                /*
                 * this is the preferred way of using a dialog 
                 * to return some value to the parent form
                 */
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Sorry, user name and password don't match.", "Error");
                /*
                 * it makes sense to return Retry as the result
                 */
                this.DialogResult = DialogResult.Retry;
            }
            this.Close();
        }

        private void PasswordView_Load(object sender, EventArgs e)
        {
            tBoxName_PF.Text = "";
            tBoxPassword_PF.Text = "";
            tBoxName_PF.Select();
        }

        private void btnCancel_PF_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void tBoxName_PF_TextChanged(object sender, EventArgs e)
        {

        }

        private void lbPassword_Click(object sender, EventArgs e)
        {

        }

        private void tBoxPassword_PF_TextChanged(object sender, EventArgs e)
        {

        }

        private void lab_Click(object sender, EventArgs e)
        {

        }
    }
}
